//
//  RootViewController.m
//  SlimmingTempo
//
//  Created by ZGS on 12-3-18.
//  Copyright 2012年 110. All rights reserved.
//

#import "RootViewController.h"

@implementation RootViewController
@synthesize helpButton;
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    
    self.navigationController.navigationBar.frame = CGRectMake(0, 20, 320, 30); 
    self.title = @"";
    
    //数据库操作
    NSString *dbName = @"/UserInfo.db";
    
    NSString *sourcePath = [NSString stringWithFormat:@"%@%@", [[NSBundle mainBundle] resourcePath], dbName];
    
    FMDatabase *database = [FMDatabase databaseWithPath:sourcePath];
    if( ![database open] ){
        NSLog(@"could not open database");
        [database release];
    }
    else{
        NSLog(@"open database ok");
    }
    
    NSString *query = @"select *from UserInfo";
    FMResultSet *rs = [database executeQuery:query];
    if (!rs)
    {
        NSLog(@"ERROR:LINE:%d Func:%s", __LINE__, __FUNCTION__);
        return;
    }
    
    while ([rs next]) 
    {
        NSLog(@"%@",[rs stringForColumn:@"userName"]);

    }
    
    [rs close];
    [database close];
    
//    IndexPage *index = [[IndexPage alloc] init];
//    [self.navigationController pushViewController:index animated:NO];
    
    
    
}


- (IBAction) toHelp:(id)sender
{
    LevelUp *vc = [[LevelUp alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
//    [self.view addSubview:vc.view];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
}

- (void)viewWillDisappear:(BOOL)animated
{
	[super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
	[super viewDidDisappear:animated];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Relinquish ownership any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload
{
    [super viewDidUnload];

    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
    // For example: self.myOutlet = nil;
}

- (void)dealloc
{
    [helpButton release];
    [super dealloc];
}

@end
